package com.aixin.project.util;

import java.io.IOException;
import java.io.Writer;

import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.parser.node.Node;

public class PersonUtil extends Directive{
	@Override
	public String getName() {
		return "togender";
	}

	@Override
	public int getType() {
		return LINE;
	}

	@Override
	public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
		Object obj = node.jjtGetChild(0).value(context);
		if(null == obj)
			writer.write("");
        else{
      			String string = (String) obj;
      			if("1".equals(string))
      			    writer.write("男");
      			else if("0".equals(string))
      				writer.write("女");
      			else
      				writer.write("");
      		}
		///AxMemcached.get(CommonConstants.MKEY_EXPERT+eid);
		//context.put(CommonConstants.MKEY_EXPERT+eid, "shabi");
		//writer.write("Hello,"+obj);
		return true;
	}
}
